/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.mapper.rfidCodeDetailMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.mapper;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.processor.*;
import com.yonyou.iuap.yms.replace.CollectionUtil;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.entity.ReRFIDCode;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.entity.coderfid;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.entity.storeRecord;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.model.DaohuoList;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.entity.StorerecordEntity;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class rfidCodeDetailMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;

    public List<ReRFIDCode> selectReRFIDCodeUp(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.`id`,a.batch_no,a.batchno_dxq,a.epc_status,b.`epc_tid`,b.`rfid_code`, b.productDate,b.invalidDate,b.`f_stock_count`,b.`id` as rfidcodeId, b.`location_id`,b.rfid_status,b.batchno,b.creator, b.warehouse_id as warehouseid,w.code as warehouseCode,w.warehouseName   FROM `dxq_storerecord` a   LEFT JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on w.id=b.warehouse_id  WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?  and a.ytenant_id=? AND a.`dr`=0 and b.`location_id` IS NOT NULL and  b.`location_id`!=''\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new ReRFIDCode());
        return (List<ReRFIDCode>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int deleteStorerecordByid(List<String> strList, String modifier, String tenant_id) throws Exception {
		if (strList == null || strList.size()==0) return 0;
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_storerecord set dr=1,modify_time=now(),modifier=? ");
		parameter.addParam(modifier);
		sqlBuilder.append(" where ytenant_id=? and dr=0 ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" and id in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}else{
			sqlBuilder.append(" and id in ('')");
		}
        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<coderfid> selectByIds(List<String> strList, String tenant_id) throws Exception {
		if (strList==null || strList.size()==0) return new ArrayList<>();
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from `dxq_coderfid` where ytenant_id=? ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" and id in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new coderfid());
        return (List<coderfid>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int InsertStorerecordList(String ordercode, String orderid, String ordertype, int orderstatus, String rfidcodeId, String orderdetailid, int dr, String tenant_id, String pk_temp, int version, String creator, String modifier, String id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "insert into `dxq_storerecord`(`ordercode`,`orderid`,`ordertype`,`orderstatus`, `rfidcodeId`,`orderdetailid`,`dr`,`tenant_id`,`ytenant_id`,`pk_temp`,`version`, `create_time`,`modify_time`,`creator`,`modifier`,id)  values(?,?,?,?, ?,?,?,?,?,?,?,  now(),now(),?,?,?)\n";
        parameter.addParam(ordercode);
		parameter.addParam(orderid);
		parameter.addParam(ordertype);
		parameter.addParam(orderstatus);
		parameter.addParam(rfidcodeId);
		parameter.addParam(orderdetailid);
		parameter.addParam(dr);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(pk_temp);
		parameter.addParam(version);
		parameter.addParam(creator);
		parameter.addParam(modifier);
		parameter.addParam(id);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<StorerecordEntity> selectReRFIDStatusCount(List<String> orderdetailids, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" SELECT a.* FROM `dxq_storerecord` a where a.ytenant_id=? AND a.`dr`=0 ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(orderdetailids)) {
			sqlBuilder.append(" and a.`orderdetailid` in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < orderdetailids.size(); index++) {
				String item = orderdetailids.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < orderdetailids.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);

		//return (List<StorerecordEntity>) ymsJdbcApi.queryForDTOList(sql, parameter, StorerecordEntity.class);
    }


    public List<ReRFIDCode> getPickingDetail(String orderid, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  b.`epc_tid`,b.`rfid_code`,b.`f_stock_count`,b.productDate,b.invalidDate, b.`location_id`, b.product_id,b.`id` as rfidcodeId,b.creator,b.product_sku_id,b.batchno, a.orderdetailid,a.orderid,a.`id`,a.batch_no,a.batchno_dxq,a.epc_status, w.code as warehouseCode,w.warehouseName,b.warehouse_id as warehouseid   FROM `dxq_storerecord` a inner JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on w.id=b.warehouse_id   WHERE a.`orderid`=? and b.rfid_status in (4,5) and b.dr=0  and a.ytenant_id=? AND a.`dr`=0;\n";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new ReRFIDCode());
        return (List<ReRFIDCode>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public storeRecord selectByid(String rfidcodeId, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from `dxq_storerecord`   where `rfidcodeId`= ?  AND `dr`=0 and ytenant_id=?   and (batch_no IS not NULL and batch_no !='') limit 0,1;\n";
        parameter.addParam(rfidcodeId);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanProcessor(new storeRecord());
        return (storeRecord) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }


    public int updateInstock(List<String> ids, String batch_no, String sourceid, String sourceautoid, String modifier, String Source, String Firstsource, String Firstsourceautoid, String Firstsourceid, String Upcode, String Firstupcode, String Poid, String Podetailid, String Pocode, String tenant_id, String invalidDate) throws Exception {
		if (ids == null || ids.size()==0) return 0;
		SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_storerecord set epc_status=0,batch_no=?,modify_time=now(),modifier=?, sourceid=?, sourceautoid=?, source=?, firstsourceid=?, firstsourceautoid=?, firstsource=?, upcode=?, firstupcode=?,invalidDate=?, poid=?, podetailid=?, pocode=? ");
		parameter.addParam(batch_no);
		parameter.addParam(modifier);
		parameter.addParam(sourceid);
		parameter.addParam(sourceautoid);
		parameter.addParam(Source);
		parameter.addParam(Firstsourceid);
		parameter.addParam(Firstsourceautoid);
		parameter.addParam(Firstsource);
		parameter.addParam(Upcode);
		parameter.addParam(Firstupcode);
		parameter.addParam(invalidDate);
		parameter.addParam(Poid);
		parameter.addParam(Podetailid);
		parameter.addParam(Pocode);

		sqlBuilder.append(" where ytenant_id=? AND `dr`=0 ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(ids)) {
			sqlBuilder.append(" and id in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < ids.size(); index++) {
				String item = ids.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < ids.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}else{
			sqlBuilder.append(" and id in ('')");
		}

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<StorerecordEntity> getDaohuoListRecord(String orderid, String tenant_id, String creator) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT a.*   FROM `dxq_storerecord` a   WHERE a.`orderid`=? and a.creator=?   and (a.batch_no IS NULL or a.batch_no='')  AND a.`dr`=0 and a.ytenant_id=?  order by a.id\n";
        parameter.addParam(orderid);
		parameter.addParam(creator);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public List<ReRFIDCode> selectReRFIDCodeAll(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.`id`,a.rfidcodeId,a.batch_no,a.batchno_dxq,a.epc_status,a.rfidcode `rfid_code`, a.productDate,a.`f_stock_count`,a.invalidDate,a.`epc_tid`,a.batchno, IFNULL(b.rfid_status,a.epc_status) rfid_status, IFNULL(b.location_id,a.locationId) location_id, a.creator,a.warehouse_id as warehouseid, w.code as warehouseCode,w.warehouseName   FROM `dxq_storerecord` a LEFT JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on w.id=a.warehouse_id  WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?  and a.ytenant_id=? and (a.dr=0 or a.epc_status=6);\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new ReRFIDCode());
        return (List<ReRFIDCode>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

	/**
	 * 返回库存状态 4已拣货，5已配货 数据列表
	 * @param orderid
	 * @param tenant_id
	 * @return
	 * @throws Exception
	 */
    public List<StorerecordEntity> getPickingDetailRecord(String orderid, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.*   FROM `dxq_storerecord` a inner JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   WHERE a.`orderid`=? and b.epc_status in (4,5) and b.dr=0  and a.ytenant_id=? AND a.`dr`=0;\n";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int deleteStorerecord(String rfidcodeId, String modifier, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update dxq_storerecord set  dr=1,modify_time=now(),modifier=?  where rfidcodeId=? and ytenant_id=?  and dr=0\n";
        parameter.addParam(modifier);
		parameter.addParam(rfidcodeId);
		parameter.addParam(tenant_id);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<ReRFIDCode> selectReRFIDCodeNoup(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.`id`,a.batch_no,a.batchno_dxq,a.epc_status,b.`epc_tid`,b.`rfid_code`,  b.productDate,b.invalidDate,b.`id` as rfidcodeId,b.`f_stock_count`,b.batchno, b.`location_id`,b.rfid_status,b.creator,b.warehouse_id as warehouseid, w.code as warehouseCode,w.warehouseName   FROM `dxq_storerecord` a   LEFT JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on w.id=b.warehouse_id    WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?   and a.ytenant_id=? AND a.`dr`=0 and (b.location_id IS NULL or b.`location_id`='')\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new ReRFIDCode());
        return (List<ReRFIDCode>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int InsertStorerecordOut(String ordercode, String orderid, String ordertype, Integer orderstatus, String rfidcodeId, String orderdetailid, String stockId, String stockUnitId, String priceUOM, String invExchRate, String unitExchangeType, String invPriceExchRate, String unitExchangeTypePrice, String sourceid, String sourceautoid, String source, String firstsourceid, String firstsourceautoid, String firstsource, String upcode, String firstupcode, String poid, String podetailid, String pocode, String tenant_id, String pk_temp, int version, String creator, String modifier, String id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "INSERT INTO `dxq_storerecord`(`ordercode`,`orderid`,`ordertype`,`orderstatus`, `rfidcodeId`,`orderdetailid`,`stockId`, `stockUnitId`,`priceUOM`,`invExchRate`, `unitExchangeType`,`invPriceExchRate`,`unitExchangeTypePrice`, `sourceid`,`sourceautoid`,`source`, `firstsourceid`,`firstsourceautoid`,`firstsource`, `upcode`,`firstupcode`,`poid`,`podetailid`,`pocode`, `dr`,`tenant_id`,`ytenant_id`,`pk_temp`,`version`, `create_time`,`modify_time`,`creator`,`modifier`,id)  VALUES (?,?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?, ?,?,?,?,?, 0,?,?,?,?, now(),now(),?,?,?)\n";
        parameter.addParam(ordercode);
		parameter.addParam(orderid);
		parameter.addParam(ordertype);
		parameter.addParam(orderstatus);
		parameter.addParam(rfidcodeId);
		parameter.addParam(orderdetailid);
		parameter.addParam(stockId);
		parameter.addParam(stockUnitId);
		parameter.addParam(priceUOM);
		parameter.addParam(invExchRate);
		parameter.addParam(unitExchangeType);
		parameter.addParam(invPriceExchRate);
		parameter.addParam(unitExchangeTypePrice);
		parameter.addParam(sourceid);
		parameter.addParam(sourceautoid);
		parameter.addParam(source);
		parameter.addParam(firstsourceid);
		parameter.addParam(firstsourceautoid);
		parameter.addParam(firstsource);
		parameter.addParam(upcode);
		parameter.addParam(firstupcode);
		parameter.addParam(poid);
		parameter.addParam(podetailid);
		parameter.addParam(pocode);
		parameter.addParam(tenant_id);
		parameter.addParam(tenant_id);
		parameter.addParam(pk_temp);
		parameter.addParam(version);
		parameter.addParam(creator);
		parameter.addParam(modifier);
		parameter.addParam(id);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<StorerecordEntity> selectEpcUpRecord(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.*  FROM `dxq_storerecord` a   WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?  and a.ytenant_id=? AND a.`dr`=0  and a.epc_status>0 and (a.`locationId` IS NOT NULL and a.`locationId`!='')\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public List<StorerecordEntity> selectEpcNoupRecord(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.*  FROM `dxq_storerecord` a   WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?   and a.ytenant_id=? AND a.`dr`=0  and a.epc_status=0 and (a.locationId IS NULL or a.`locationId`='')\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public int updateOut(String id, String batch_no, String sourceid, String sourceautoid, String modifier, String Source, String Firstsource, String Firstsourceautoid, String Firstsourceid, String Upcode, String Firstupcode, String Poid, String Podetailid, String Pocode, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update dxq_storerecord set epc_status=6,batch_no=?,modify_time=now(),modifier=?, sourceid=?,sourceautoid=?,source=?, firstsourceid=?,firstsourceautoid=?,firstsource=?, upcode=?, firstupcode=?, dr=1, poid=?, podetailid=?, pocode=?  where  `id`=? and ytenant_id=? AND `dr`=0;\n";
        parameter.addParam(batch_no);
		parameter.addParam(modifier);
		parameter.addParam(sourceid);
		parameter.addParam(sourceautoid);
		parameter.addParam(Source);
		parameter.addParam(Firstsourceid);
		parameter.addParam(Firstsourceautoid);
		parameter.addParam(Firstsource);
		parameter.addParam(Upcode);
		parameter.addParam(Firstupcode);
		parameter.addParam(Poid);
		parameter.addParam(Podetailid);
		parameter.addParam(Pocode);
		parameter.addParam(id);
		parameter.addParam(tenant_id);

        
        return ymsJdbcApi.update(sql, parameter);
    }


    public List<DaohuoList> getDaohuoList(String orderid, String tenant_id, String creator) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT a.orderdetailid,a.orderid,a.`ordercode`,a.id as recordid,a.batchno_dxq, b.batchno,b.id,b.rfid_code,b.`f_stock_count`,b.`productDate`, b.warehouse_id,b.product_id,b.product_sku_id, w.code as warehouse_code,w.warehouseName as warehouse_name  FROM `dxq_storerecord` a LEFT JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on w.id=b.warehouse_id   WHERE a.`orderid`=? and a.ytenant_id=? and a.creator=?   and (a.batch_no IS NULL or a.batch_no='')  AND a.`dr`=0 and b.dr=0 order by a.id\n";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);
		parameter.addParam(creator);

        ResultSetProcessor processor = new AutoBeanListProcessor(new DaohuoList());
        return (List<DaohuoList>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }


    public List<coderfid> selectByEpcs(List<String> strList, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from `dxq_coderfid` where `dr`=0 and ytenant_id=? ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" and `rfid_code` in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new coderfid());
        return (List<coderfid>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    public List<StorerecordEntity> selectEpcRecord(String orderid, String orderdetailid, String ordertype, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  a.*  FROM `dxq_storerecord` a  WHERE a.`orderid`=? AND a.`orderdetailid`=? AND a.`ordertype`=?  and a.ytenant_id=? and (a.dr=0 or a.epc_status=6);\n";
        parameter.addParam(orderid);
		parameter.addParam(orderdetailid);
		parameter.addParam(ordertype);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    public List<StorerecordEntity> selFaRFIDStatusCount(List<String> orderdetailids, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" SELECT a.* FROM `dxq_storerecord` a WHERE a.ytenant_id=? and (a.dr=0 or a.epc_status=6) ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(orderdetailids)) {
			sqlBuilder.append(" and a.`orderdetailid` in ");
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < orderdetailids.size(); index++) {
				String item = orderdetailids.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < orderdetailids.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new StorerecordEntity());
        return (List<StorerecordEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

}
